<?php

namespace App\Models\Scm;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Material extends Model
{
    use HasFactory;
    public $timestamps = FALSE;
    protected $table = 'biz_material';
    protected $fillable = ['id', 'category_id', 'name', 'code', 'specifi', 'unit', 'material_nature', 'minumum_order_num', 'tax_rate', 'anticipated_price', 'latest_price', 'pic_url', 'remark', 'status', 'del_flag', 'tenant_id', 'total_weight', 'single_weight', 'size', 'weight_unit', 'material_desc', 'latest_price_date', 'kingdee_code', 'kingdee_id', 'product_cycle', 'material_param', 'pic_name', 'kingdee_unit', 'kingdee_unit_name', 'create_time', 'update_time'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
    }

    public function insertOne($params){
        return self::create($params);
    }

    public function insertMany($params){
        return self::insert($params);
    }

    public function updateById($params, $id){
        return self::where("id", $id)->update($params);
    }

    public function findRowById($id){
        return self::whereRaw('BINARY id = ?', [$id])->first();
    }
}
